home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v10n06.arc / TESTXBUF.C < prev    next >
Text File  |  1991-03-06  |  856b  |  38 lines

  1. // testxbuf.C - demonstrates use of XBUF buffer
  2. //
  3. // Use C>TESTXBUF to run without extended buffering
  4. // Use C>TESTXBUF 1 to run *with* extended buffering
  5.  
  6. #include<conio.H>
  7. #include<dos.H>
  8. #include<stdio.H>
  9. #include"xbuf.H"
  10.  
  11. void main(int argc, char **argv)
  12.     {
  13.     int key, XBUF = 0;
  14.  
  15.     if(argc > 1)
  16.         XBUF = 1;
  17.     if(XBUF)
  18.         xbuf_install(DEFAULT_SIZE);
  19.     sleep(5);  // Wait 5 seconds
  20.  
  21.     if(XBUF)
  22.         while(iskey())
  23.             {
  24.             key = getkey();
  25.             printf((key > 31 && key < 128) ? "%c " : "%x ", key);
  26.             }
  27.     else
  28.         while(kbhit())
  29.             {
  30.             key = getch();
  31.             if(!key)
  32.                 key = getch() << 8;
  33.             printf((key > 31 && key < 128) ? "%c " : "%x ", key);
  34.             }
  35.     if(XBUF)
  36.         xbuf_remove();
  37.     }
  38.